'use strict';
/**
 *
 * Created by hedingxin on 2019-03-05
 */
var browserSync = require('browser-sync');
var fs = require('fs');
var fs = require('fs');
var fs = require('fs');
var path = require('path');
var path = require('path');
var path = require('path');
var path = require('path');
var path = require('path');
var path = require('path');
var path = require('path');
var path = require('path');
var path = require('path');
var path = require('path');
var path = require('path');
function fsExistsSync(path) {
  try {
    fs.accessSync(path);
  } catch (e) {
    return false;
  }
  return true;
}

var isLayout = fsExistsSync(path.join(__dirname, 'en/page/layout.html'));
var index = isLayout
    ? 'en/page/layout.html'
    : 'en/page/index.html';
browserSync({
  server: {
    middleware: [
      function(req, res, next) {
        if (req.url == '/') {
          res.writeHead(301, {
            Location: index
          });
          return res.end();
        }
        next();
      }
    ]
  },
  startPath: index,
  port: 8001,
  files: ['./en'],
  host: '192.168.9.244'//自己的ip
});
